
var gulp = require('gulp');
var rename = require('gulp-rename');
var babel = require('gulp-babel');
var plumber = require('gulp-plumber');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var seajsCombo = require('gulp-seajs-combo');

//sea.js

gulp.task('jsStep', function(){
    return gulp.src('js/mod/*.js')
        .pipe(plumber())
        .pipe(babel())
        .pipe(gulp.dest('./dist/js/mod/'));
});

gulp.task('js6', function(){
    return gulp.src('./js/mod/*.js')
        .pipe(plumber())
        .pipe(babel())
        .pipe(gulp.dest('./dist/js/mod/'))
        .pipe(uglify())
        .pipe(rename({
            extname: '\.min.js'
        }))
        .pipe(gulp.dest('dist/js/mod'))
});

gulp.task('seaJs', ['jsStep'], function () {  
    gulp.src('dist/js/mod/test.js')
    .pipe(plumber())
    .pipe(seajsCombo())
    .pipe(rename({
        extname : '\.min.js'
    }))
    .pipe(gulp.dest('dist/js/mod'));
});

gulp.task('default', function(){
    //gulp.watch('js/mod/*.js', ['seaJs']);
    gulp.watch('js/mod/*.js', ['js6']);
});